package com.ybkj.o2o.zhuanche.service.impl;

import com.ybkj.o2o.zhuanche.entity.OrderTemp;
import com.ybkj.o2o.zhuanche.entity.OrderTempCriteria;
import com.ybkj.o2o.zhuanche.mapper.BaseMapper;
import com.ybkj.o2o.zhuanche.mapper.OrderTempMapper;
import com.ybkj.o2o.zhuanche.service.OrderTempService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class DefaultOrderTempService extends
    AbstractBaseService<OrderTemp, OrderTempCriteria, Long> implements OrderTempService {

  @Autowired
  private OrderTempMapper orderTempMapper;

  @Override
  public int insert(OrderTemp orderTemp) {
    Assert.notNull(orderTemp.getAppkey());
    Date date2 = new Date();
    orderTemp.setCreated(date2);
    orderTemp.setUpdated(date2);
    orderTemp.setLasturge(date2);
    orderTemp.setStatus(0);
    orderTemp.setReview(false);
    orderTemp.setTreatment(false);
    orderTemp.setVersion(1L);
    return orderTempMapper.insert(orderTemp);
  }

  @Override
  public OrderTemp findByIdAndAppKey(Long orderId, String appKey) {
    return orderTempMapper.findByIdAndAppKey(orderId,appKey);
  }

  @Override
  public BaseMapper<OrderTemp, OrderTempCriteria, Long> getMapper() {
    return orderTempMapper;
  }

  @Override
  public List<OrderTemp> queryByGroupId(Long groupId, String appKey) {
    return orderTempMapper.queryByGroupId(groupId,appKey);
  }

@Override
public List<Map<String, Object>> countBookTempDriver(Long zhuanYuyueMax,
		Date zhuanYuyueTime, String appKey) {
	return orderTempMapper.countBookTempDriver(zhuanYuyueMax, zhuanYuyueTime, appKey);
}

}
